<?php
namespace frontend\controllers;

use frontend\models\ResendVerificationEmailForm;
use frontend\models\VerifyEmailForm;
use Yii;
use yii\base\InvalidArgumentException;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
use frontend\models\ContactForm;

/**
 * Site controller
 */
class Yii2Controller extends Controller
{
    public $layout = "@frontend/modules/yii/views/layouts/manager";

    public function beforeAction($action)
    {
        \Yii::$app->params["header"] = [
            "left" => [
                ['label' => 'Bootstrap1', 'url' => ['/yii2/bootstrap']],
            ],
            "right" => [
                ['label' => 'About', 'url' => ['/yii/bootstrap/about']],
                ['label' => 'Contact', 'url' => ['/yii/bootstrap/contact']],
            ]
        ];
        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }

    public function actionIndex(){
        return $this->render("index");
    }

    public function actionBootstrap(){
        \Yii::$app->params["sidebar"] = [];
        $this->layout = "@frontend/modules/yii/views/layouts/main";
        return $this->render("bootstrap");
    }

    public function actionHome(){
        $this->layout = "cms";
        $params = Yii::$app->request->post();
        if(isset($params["page"])) {
            return $this->renderAjax("overview");
        }
        return $this->render("home");
    }


    public function actionBootstrap3(){
        $this->layout = false;
        $params = Yii::$app->request->post();
        if(isset($params["page"])) {
            return $this->renderAjax("/yii2/bootstrap3/" . $params["page"]);
        }
        $article = "";
        if (Yii::$app->request->isGet) {
            $page = Yii::$app->request->get("page", "overview");
            $article = $this->renderAjax("/yii2/bootstrap3/" . $page);
        }
        return $this->render("/yii2/bootstrap3/index", [
            'article' => $article
        ]);
    }
}
